<template>
	<view>
		<statusBar />
		<!-- #ifdef APP-PLUS||H5-->
		<button class="" @click="appLogin">APP微信授权登录</button>
		<view class="nav">
			<view>{{this.Name.nickName}}</view>
			<image :src="this.Name.avatarUrl" mode=""></image>
		</view>
		
		<!-- #endif -->
	</view>
</template>
<script>
import { mapActions, mapState } from 'vuex';
import { toast } from '@/utils/toast';
import request from '@/utils/request';
import sqBtn from '@/components/sq-btn.vue';
import statusBar from '../../components/statusBar/statusBar.vue';
export default {
	data() { 
		return {
			Name:""
		};
	},
	components: {
		sqBtn,
		statusBar
	},
	methods:{
		appLogin: function() {
			uni.getProvider({
				service: 'oauth',
				success: function(res) {
					console.log(res.provider);
					//支持微信、qq和微博等
					if (~res.provider.indexOf('weixin')) {
						uni.login({
							provider: 'weixin',
							success: function(loginRes) {
								console.log('-------获取openid(unionid)-----');
								console.log(JSON.stringify(loginRes));
								// 获取用户信息
								uni.getUserInfo({
									provider: 'weixin',
									success: function(infoRes) {
										// console.log('-------获取微信用户所有-----');
										// console.log(JSON.stringify(infoRes.userInfo));
										this.Name =JSON.stringify(infoRes.userInfo) 
										console.log(this.Name,1111)
									}
								});
							}
						});
					}
				}
			});
		},
	}
};
</script>
<style lang="scss" scoped>
	.nav{
		width: 100upx;
		height: 100upx;
		border: 1upx solid red;
		image{
			width: 100upx;
			height: 100upx;
		}
	}
</style>
